package com.easyadmin.modules.stock.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.modules.stock.domain.SysStockTarget;
import com.easyadmin.modules.stock.domain.SysStockValueEntity;
import com.easyadmin.modules.stock.mapper.SysStockTargetDao;
import com.easyadmin.modules.stock.mapper.SysStockValueDao;
import com.easyadmin.modules.stock.service.SysStockValueService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;


@Service("sysStockValueService")
public class SysStockValueServiceImpl extends ServiceImpl<SysStockValueDao, SysStockValueEntity> implements SysStockValueService {

    @Autowired
    SysStockValueDao sysStockTargetDao;


    @Override
    public PageInfo<SysStockValueEntity> queryPage(SysStockValueEntity sysStockTarget, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<SysStockValueEntity> data =sysStockTargetDao.selectList(new QueryWrapper<>());
        return new PageInfo<>(data);
    }

    /**
     * Describe: 根据 id 删除某条数据
     * Param: id
     * Return: Boolean
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean remove(String id) {
        sysStockTargetDao.deleteById(Integer.valueOf(id));
        return true;
    }
    /**
     * Describe: 修改用户数据
     * Param: SysUser
     * Return: 操作结果
     */
    @Override
    public boolean update(SysStockValueEntity sysFactorEntity) {
        Integer result = sysStockTargetDao.updateById(sysFactorEntity);
        return result > 0;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchRemove(String[] ids) {
        for(String  id:ids){
            sysStockTargetDao.deleteById(id);
        }
        return true;
    }

}